package com.qf.commons.sentinel.config.exception;


import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.qf.commons.standar.exception.IExceptionHandler;
import com.qf.data.base.r.Codes;
import com.qf.data.base.r.R;
import com.qf.data.base.r.Rs;

/**
 * 微服务内部的 降级异常处理器
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
public class IntervelSentinelExceptionHandler implements IExceptionHandler {

    @Override
    public boolean isSupport(Exception e) {
        return e instanceof DegradeException;
    }

    @Override
    public R exceptionHandler(Exception e) {
        return Rs.createFail(Codes.SERVICE_DEGRADE);
    }
}
